<template>
  <div>
    <div class="formTit">[{{mainData.name}}]
        {{permissI18n('subField','子表字段权限设置')}}</div>
        <form-permission-user-main ref="tabMain" :mainData="mainData.fields"></form-permission-user-main>
        <template v-if="mainData.buttons && mainData.buttons.length>0">
            <div class="formTit">[{{mainData.name}}]
                {{permissI18n('subTabBtn','子表按钮权限设置')}}
            </div>
            <form-permission-user-tab-btn ref="tabBtn" :mainData="mainData.buttons"></form-permission-user-tab-btn>
        </template>
  </div>
</template>
<script>
  import {BaseForm, RxDialog} from "@lowcode/jpaas-common-lib";
  import FormPermissionUserMain from './FormPermissionUserMain';
  import FormPermissionUserTabBtn from './FormPermissionUserTabBtn';


  export default {
    name: 'FormSubPermissionEdit',
    mixins: [BaseForm],
    components: {
      RxDialog,
      FormPermissionUserMain,
      FormPermissionUserTabBtn,
    },
    props: {
      mainData: {
        type: Object,
        default: {}
      }
    },
    data() {
      return {
        formSolutionId: "",
        permissionData: [],
        shouMain: false
      }
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"formPermiss",key);
      },
      permissI18n(name,text,key){
          return this.$ti18(name,text,"formPermiss.list",key)+" "+this.$ti18("permissSet","权限设置","formPermiss.list",key);
      },
      getMainData() {
        var saveData= {
          alias:this.mainData.alias,
          dataObj:{
            "fields":this.$refs.tabMain.getMainData(),
            "buttons":this.$refs.tabBtn?this.$refs.tabBtn.getMainData():{}
          }
        };
        return saveData;
      }
    }
  }
</script>
<style scoped>
  .formTit{
    padding: 10px 0 0 20px;
    color: #555;
    font-size: 14px;
  }
</style>